﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using Smartec.Framework.Web.MVC;
using Smartec.Accounts.Camel.AMS.Model.Facades;
using Smartec.Framework.Web.Common.Managers;
using Smartec.Accounts.Camel.AMS.WebApp.Controllers;
using Smartec.Accounts.Camel.AMS.Model.Entities.Validation;
using Smartec.Accounts.Camel.AMS.Model.Entities.Attributes;

namespace Smartec.Accounts.Camel.AMS.WebApp
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : SmartecMVCGlobal
    {
        public override void RegisterGlobalFilters(GlobalFilterCollection filters)
        {
            base.RegisterGlobalFilters(filters);
        }

        public override void RegisterRoutes(RouteCollection routes)
        {
            //routes.MapRoute(
            //    "Addresses", // Route name
            //    "Addresses/_index/{selectedCountryID}/{selectedCityID}", // URL with parameters
            //    new { controller = "Addresses", action = "_index", selectedCountryID = UrlParameter.Optional, selectedCityID = UrlParameter.Optional }); // Parameter defaults

            routes.MapRoute(
                "Defaultlang", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
            );
            base.RegisterRoutes(routes);
        }

        protected override void Application_Start()
        {
            DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(CustomRegularExpressionAttribute), typeof(RegularExpressionAttributeAdapter));
            DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(CustomLengthAttribute), typeof(StringLengthAttributeAdapter));
            base.Application_Start();

            //GlobalFilters.Filters.Add(new AuthorizeAttribute { Roles = "Administrator" });

            //var attributes = typeof(CompaniesController).GetMethod("Index").GetCustomAttributes(typeof(AuthorizeAttribute), false) as AuthorizeAttribute[];
                 

            //attributes[0].Roles = "Administrator";

        }

        //protected void Application_BeginRequest(object sender, EventArgs e)
        //{
            
        //}
    }
}